﻿<phone:PhoneApplicationPage x:Class="dIRca.WP7.Views.SettingsView"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
                            xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:blend="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                            xmlns:command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP7"
                            xmlns:behaviors="clr-namespace:WP7Contrib.View.Controls.Behaviors;assembly=WP7Contrib.View.Controls"
                            xmlns:toolkitPrimitives="clr-namespace:Microsoft.Phone.Controls.Primitives;assembly=Microsoft.Phone.Controls.Toolkit"
                            mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696" 
                            FontFamily="{StaticResource PhoneFontFamilyNormal}"
                            FontSize="{StaticResource PhoneFontSizeNormal}"
                            Foreground="{StaticResource PhoneForegroundBrush}"
                            SupportedOrientations="PortraitOrLandscape"
                            Orientation="Portrait"
                            shell:SystemTray.IsVisible="True"
                            DataContext="{Binding SettingsViewModel, Source={StaticResource Locator}}">

    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>
    <Grid x:Name="LayoutRoot"
          Background="{StaticResource PhoneBackgroundBrush}">
        <blend:Interaction.Triggers>
            <blend:EventTrigger EventName="Loaded">
                <command:EventToCommand Command="{Binding LayoutRootCommand}" CommandParameter="{Binding ElementName=LayoutRoot}" PassEventArgsToCommand="True"/>
            </blend:EventTrigger>
        </blend:Interaction.Triggers>
        <Grid>
            <controls:Pivot Title="{Binding PageTitle}"
                            Style="{StaticResource SmallPivotStyle}">
                <controls:PivotItem Header="General" Style="{StaticResource SmallPivotItemStyle}">
                    <ScrollViewer>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock x:Name="textBlockConnectOnStartup" Text="Connect on Startup" Style="{StaticResource TextSmallStyle}" Grid.Row="0" Grid.Column="0" />
                            <toolkitPrimitives:ToggleSwitchButton x:Name="toggleSwitchButtonConnectOnStartup" IsChecked="{Binding Client.ConnectOnStartup, Mode=TwoWay}" Grid.Row="0" Grid.Column="1" />
                            <TextBlock x:Name="textBlockReconnectOnDisconnect" Text="Reconnect on Disconnect" Style="{StaticResource TextSmallStyle}" Grid.Row="1" Grid.Column="0" />
                            <toolkitPrimitives:ToggleSwitchButton x:Name="toggleSwitchButtonReconnectOnDisconnect" IsChecked="{Binding Client.ReconnectOnDisconnect, Mode=TwoWay}" Grid.Row="1" Grid.Column="1" />
                            <TextBlock x:Name="textBlockDefaultPort" Text="Default Port" Style="{StaticResource TextSmallStyle}" Grid.Row="2" Grid.Column="0" />
                            <TextBox x:Name="textBoxDefaultPort" Text="{Binding Client.DefaultPort, Mode=TwoWay}" InputScope="Number" Grid.Row="2" Grid.Column="1" />
                            <TextBlock x:Name="textBlockWindowBuffer" Text="Window Buffer Size" Style="{StaticResource TextSmallStyle}" Grid.Row="3" Grid.Column="0" />
                            <TextBox x:Name="textBoxWindowBuffer" Text="{Binding Client.WindowBuffer, Mode=TwoWay}" InputScope="Number" Grid.Row="3" Grid.Column="1" />
                            <TextBlock x:Name="textBlockAutoScroll" Text="Auto Scroll on Output" Style="{StaticResource TextSmallStyle}" Grid.Row="4" Grid.Column="0" />
                            <toolkitPrimitives:ToggleSwitchButton x:Name="toggleSwitchButtonAutoScroll" IsChecked="{Binding Client.AutoScrollOnOutput, Mode=TwoWay}" Grid.Row="4" Grid.Column="1" />
                        </Grid>
                    </ScrollViewer>
                </controls:PivotItem>
                <controls:PivotItem Header="User" Style="{StaticResource SmallPivotItemStyle}">
                    <ScrollViewer>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock x:Name="textBlockUserNickName" Text="NickName" Style="{StaticResource TextSmallStyle}" Grid.Row="0" Grid.Column="0" />
                            <TextBox x:Name="textBoxUserNickName" Text="{Binding Client.User.NickName, Mode=TwoWay}" InputScope="Text" Grid.Row="0" Grid.Column="1" />
                            <TextBlock x:Name="textBlockUserNickNameAlternates" Text="NickName Alternates" Style="{StaticResource TextSmallStyle}" Grid.Row="1" Grid.Column="0" />
                            <TextBox x:Name="textBoxUserNickNameAlternates" Text="{Binding Client.User.NickNameAlternates, Mode=TwoWay}" InputScope="Text" Grid.Row="1" Grid.Column="1" />
                            <TextBlock x:Name="textBlockUserName" Text="Name" Style="{StaticResource TextSmallStyle}" Grid.Row="2" Grid.Column="0" />
                            <TextBox x:Name="textBoxUserName" Text="{Binding Client.User.Name, Mode=TwoWay}" InputScope="Text" Grid.Row="2" Grid.Column="1" />
                            <TextBlock x:Name="textBlockUserEmail" Text="Email" Style="{StaticResource TextSmallStyle}" Grid.Row="3" Grid.Column="0" />
                            <TextBox x:Name="textBoxUserEmail" Text="{Binding Client.User.Email, Mode=TwoWay}" InputScope="EmailNameOrAddress" Grid.Row="3" Grid.Column="1" />
                            <TextBlock x:Name="textBlockUserQuit" Text="Quit Message" Style="{StaticResource TextSmallStyle}" Grid.Row="4" Grid.Column="0" />
                            <TextBox x:Name="textBoxUserQuit" Text="{Binding Client.User.QuitMessage, Mode=TwoWay}" InputScope="Text" Grid.Row="4" Grid.Column="1" />
                        </Grid>
                    </ScrollViewer>
                </controls:PivotItem>
                <controls:PivotItem Header="Servers" Style="{StaticResource SmallPivotItemStyle}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <ListBox x:Name="listBoxServers"
                                 ItemsSource="{Binding Servers.View}"
                                 ItemTemplate="{StaticResource ServerTemplate}"
                                 Grid.Column="0" Grid.Row="0" />
                    </Grid>
                </controls:PivotItem>
                <controls:PivotItem Header="Networks" Style="{StaticResource SmallPivotItemStyle}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <ListBox x:Name="listBoxNetworks"
                             ItemsSource="{Binding Networks.View}"
                             ItemTemplate="{StaticResource NetworkTemplate}"
                             Grid.Column="0" Grid.Row="0" />
                    </Grid>
                </controls:PivotItem>
            </controls:Pivot>
        </Grid>
    </Grid>
    
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Opacity="1">
            <shell:ApplicationBarIconButton
                x:Name="saveIcon"
                IconUri="/icons/appbar.save.rest.png"
                Text="Save" />
            <shell:ApplicationBarIconButton
                x:Name="restoreDefaultsIcon"
                IconUri="/icons/appbar.delete.rest.png"
                Text="Defaults" />
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem x:Name="menuItemScreenshot" Text="Screenshot" />
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
    <blend:Interaction.Behaviors>
        <behaviors:ApplicationBarIconButtonCommand TextKey="Save" CommandBinding="{Binding SaveCommand}" Icon="/icons/appbar.save.rest.png" Text="Save" />
        <behaviors:ApplicationBarIconButtonCommand TextKey="Defaults" CommandBinding="{Binding RestoreDefaultCommand}" Icon="/icons/appbar.delete.rest.png" Text="Defaults" />
        <behaviors:ApplicationBarMenuItemCommand TextKey="Screenshot" CommandBinding="{Binding ScreenshotCommand}" Text="Screenshot" />
    </blend:Interaction.Behaviors>    
</phone:PhoneApplicationPage>